import urllib
import re

ss=urllib.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345').read()
p = re.compile(r'.*?and the next nothing is ([0-9]+)')
while (p.match(ss)):
    i = (int)(p.findall(ss)[0])
    ss=urllib.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%d' % i).read()
    print i
    
print ss

ss=urllib.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=2').read()
p = re.compile(r'.*?and the next nothing is ([0-9]+)')
while (p.match(ss)):
    i = (int)(p.findall(ss)[0])
    ss=urllib.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%d' % i).read()
    print i
    
print ss

